package com.zdpx.pxframework.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.zdpx.pxframework.system.api.entity.OperateLog;
import com.zdpx.pxframework.system.mapper.OperateLogMapper;
import com.zdpx.pxframework.system.service.OperateLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;




/**
* 操作日志信息 服务实现类
*
* @Description:
* @Author: Cheng Xiaoxiao
* @Date: 2022-05-24 13:27:18
*/
@Service
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements OperateLogService {
    /**
    * 获取操作日志详情
    * @param id ID
    * @return 单个操作日志详情
    */
    @Override
    public OperateLog detailById(String id){
        return this.getById(id);
    }

    /**
    * 增加操作日志信息
    * @param operateLog 操作日志对象
    */
    @Override
    public void saveOperateLog(OperateLog operateLog){
        operateLog.setJavaMethodArgs(StrUtil.sub(operateLog.getJavaMethodArgs(),0,4096));
        operateLog.setRequestArgs(StrUtil.sub(operateLog.getRequestArgs(),0,4096));
        operateLog.setResultData(StrUtil.sub(operateLog.getResultData(),0,4096));

        this.baseMapper.insert(operateLog);
    }

    /**
    * 修改操作日志信息
    * @param operateLog 操作日志对象
    */
    @Override
    public void updateOperateLogById(OperateLog operateLog){
        this.baseMapper.updateById(operateLog);
    }

    /**
    * 根据ID删除
    * @param id ID
    */
    @Override
    public void deleteById(String id){
        this.removeById(id);
    }
}
